#region OpenNETCF Copyright Information
/*
Copyright (c) 2007 OpenNETCF Consulting, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using OpenNETCF.Win32;
using System.Drawing;

namespace OpenNETCF.WindowsMobile.Ink
{
    public static class NativeMethods
    {
        public delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

        // 
        // Register the WLINKCANVAS window class. This MUST be called
        // before creating a canvas window 
        //
        [DllImport("inkctrls")]
        public static extern bool InitInkControls();

        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, out IntPtr lParam);
        
        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, out object lParam);
        
        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref PENSTYLE lParam);
        
        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref Size lParam);
        
        [DllImport("coredll")]
        public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref Interfaces.VARIANT v);
        
        [DllImport("oleaut32")]
        public extern static void VariantInit(IntPtr pv);
        
        [DllImport("oleaut32")]
        public extern static void VariantClear(IntPtr pv);
        
        [DllImport("oleaut32")]
        public extern static void VariantClear(ref Interfaces.VARIANT pv);
        
        [DllImport("oleaut32")]
        public static extern IntPtr SafeArrayCreateVector(VarEnum vt, int lb, int cElem);
        
        [DllImport("oleaut32")]
        public static extern int SafeArrayDestroy(IntPtr psa);
        
        [DllImport("oleaut32")]
        public static extern int SafeArrayAccessData(IntPtr psa, out IntPtr ppvData);
        
        [DllImport("oleaut32")]
        public static extern int SafeArrayUnaccessData(IntPtr psa);
        
        [DllImport("oleaut32")]
        public static extern int SafeArrayGetUBound(IntPtr psa, uint nDim, out int plUbound);
        
        [DllImport("oleaut32")]
        public static extern int SafeArrayGetLBound(IntPtr psa, uint nDim, out int plLbound);
        
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int SetWindowLong(IntPtr hWnd, GWL nIndex, WndProcDelegate newProc);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr GetWindowLong(IntPtr hWnd, GWL nIndex);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("coredll")]
        public static extern void mouse_event(MOUSEEVENTF dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

        [Flags()]
        public enum MOUSEEVENTF
        {
            MOVE = 0x1, /* mouse move */
            LEFTDOWN = 0x2, /* left button down */
            LEFTUP = 0x4, /*left button up */
            RIGHTDOWN = 0x8, /*right button down */
            RIGHTUP = 0x10, /*right button up */
            MIDDLEDOWN = 0x20, /*middle button down */
            MIDDLEUP = 0x40, /* middle button up */
            WHEEL = 0x800, /*wheel button rolled */
            VIRTUALDESK = 0x4000, /* map to entrire virtual desktop */
            ABSOLUTE = 0x8000, /* absolute move */
            TOUCH = 0x100000, /* absolute move */
        }
    }
}
